// components/footer/index.js
var app = getApp();
import Dialog from '../../vant/dialog/dialog';
Component({
  properties: {
    friendList: { type: Array },//好友列表
    nearberUserList: { type: Array },//附近的人
    bowlWeight:{ type : Number, default: 0},
    eggsCount:{ type : Number, default: 0},
    ticketCount:{ type : Number, default: 0},
    farmUserId:{ type : Number, default: 0},
    ydCount:{ type : Number, default: 0},
    eggToYd:{ type : Number, default: 0},
    leftUserCount:{ type : Number, default: 0},
    goldenMoney:{ type : Number, default: 0},
    eggToGolden:{ type : Number, default: 0},
    goldenToYd:{ type : Number, default: 0},
    watchAdDetailSecond:{ type : Number, default: 0},
    inviteFriendCount:{ type : Number, default: 0},
    watchAdDetailMaxCount:{ type : Number, default: 0},
    watchAdDetailFeedCount:{ type : Number, default: 0},
    buyFeedCount:{ type : Number, default: 0},
    scores:{ type : Array},  
    signRoles:{ type : Array},
    signNum:{ type : Number, default: 0},  //签到数 
    ag_id:{ type : Number, default: 0},
    newFriendCount:{ type : Number, default: 0},
  },
  data: {
    energyIsVisible: false,
    friendIsVisible: false,
    nearberUserIsVisible: false,
    exchangeIsShow: false,
    exchangeIsVisible:false,
    gradientColor: {
      '0%': '#ffd01e',
      '100%': '#ee0a24'
    },
    bowl_properties:0,
    isShowBowl:true,
    min: 1,  //默认值日期第一天1
    max: 7,  //默认值日期最后一天7
    be: 0,  //默认倍数
    isiphonex: app.globalData.isiphonex,
    isxiaomi: app.globalData.isxiaomi,
  },
  methods: {
    // 获取能量
    toEnergy() {
      console.log(' this.ag_id',this.data.ag_id);
      var that = this;
      var isLogin = app.getStorageSync("isLogin");
      if (isLogin == 0) {
        wx.navigateTo({
          url: '/pages/login/index?ag_id=' + this.data.ag_id,
        })
      }else{
        this.setData({
          energyIsVisible: true,
          isShowBowl:false
        })
      }
    },
    energyClose() {
      this.setData({
        energyIsVisible: false,
        isShowBowl:true
      })
    },
    exchangeClose() {
      this.setData({
        energyIsVisible: false,
        exchangeIsShow: false,
      })
    },
    exchangeClose(){
      this.setData({
        exchangeIsVisible: false,
        isShowBowl:true
      })
    },
    /**
     * 兑换蛋票
     */
    toExchange() {
      this.triggerEvent('exticket');
    },
    // 好友
    toFriend() {
      var that = this;
      var isLogin = app.getStorageSync("isLogin");
      if (isLogin == 0) {
        wx.navigateTo({
          url: '/pages/login/index?ag_id=' + this.data.ag_id,
        })
      }else{
        this.triggerEvent('toFriend');
        this.setData({
          friendIsVisible: true,
          isShowBowl:false
        })
      }
    },
    friendClose() {
      this.setData({
        friendIsVisible: false,
        isShowBowl:true
      })
    },
    toGetFeed(){

    },
    toSign(){
      this.triggerEvent('toSign');
    },
    toFriendApply(e) {
      console.log('toFriendApply',e)
      var type = e.currentTarget.dataset.type;
      wx.navigateTo({
        url: '/pagesFarm/pages/friendApply/index?type=' + type,
      })
    },
    goFarm(e){
      var userId = e.currentTarget.dataset.userId;
      wx.navigateTo({
        url: '/pagesFarm/pages/friend/index?userId=' + userId,
      })
    },
    goDel(e){
      var that = this;
      var friendId = e.currentTarget.dataset.friendId;
      var message = "是否要删除该好友？";
      Dialog.confirm({
          title: '删除好友',
          message
        }).then(() => {
          that.triggerEvent('delFriend',friendId);
        })
        .catch(() => {
          Dialog.close();
        });
    },
    goMyTicket(){
      wx.navigateTo({
        url: '/pagesFarm/pages/ticket/index',
      })
    },
    goWeiShi(e){
      console.log('组件  goWeiShi')
      this.triggerEvent('weishi');
    },
    toCengChi(){
      this.triggerEvent('cengchi');
    },
    goExchangeYd(){
      this.triggerEvent('exchangeYd');
    },
    exchagneEgg(e){
      var isLogin = app.getStorageSync("isLogin");
      if (isLogin == 0) {
        wx.navigateTo({
          url: '/pages/login/index?ag_id=' + this.data.ag_id,
        })
      }else{
        console.log('组件  exchagneEgg')
        // this.triggerEvent('exchange');
        this.setData({
          exchangeIsVisible:true,
          isShowBowl:false
        })
      }
    },
    goHome(){
      wx.switchTab({
        url: '/pages/home/home',
      })
    },
    toScan(){
      var isLogin = app.getStorageSync("isLogin");
      if (isLogin == 0) {
        wx.navigateTo({
          url: '/pages/login/index?ag_id=' + this.data.ag_id,
        })
      }else{
        console.log('组件  exchagneEgg')
        this.triggerEvent('scancode');
      }
    },
    searchScrollLower(){
        this.triggerEvent('loadmore');
    }
  }
})
